<template>
	<el-config-provider :locale="lang" :message="<any>messageConfig" size="default">
		<router-view v-cloak v-if="appStore.isAlive"/>
	</el-config-provider>
</template>

<script lang="ts" setup>
import {computed, reactive} from 'vue'
import {useI18n} from 'vue-i18n'
import iconfontInit from '@/utils/iconUtil'
import {useWebConfigStore} from '@/stores/modules/webConfig.store'
import type {MessageConfigContext} from 'element-plus/es/components/message/src/message'
import {useAppStore} from '@/stores/modules/app.store'
import type {Language} from 'element-plus/es/locale'

const webConfigStore = useWebConfigStore()
const appStore = useAppStore()

// element 的语言包跟随语言设置切换
const {getLocaleMessage} = useI18n()
const lang = computed<Language>(() => {
	return getLocaleMessage(webConfigStore.lang.defaultLang)
})

// element 消息配置
const messageConfig = reactive<MessageConfigContext>({
	max: 5
})

// 初始化图标资源
iconfontInit()
</script>

<style lang="scss" scoped>
[v-cloak] {
	display: none !important;
}
</style>
